﻿using System.Web.Mvc;
using PortalWeb.CMS.Core.IManager;
using PortalWeb.Models.Cms;

namespace PortalWeb.Controllers.Cms
{
    public class CategoryController : Controller
    {
        private readonly ICategoryManager _categoryManager;

        public CategoryController(ICategoryManager categoryManager)
        {
            _categoryManager = categoryManager;
        }

        //
        // GET: /ProductClass/
        public ActionResult Index(string model)
        {
            //var data = CategoryManager.LoadEntities(p => p.Model == model).Select(c => new CategoryViewModel()
            //{
            //    Id = c.Id,
            //    Name = c.Name,
            //});
            return View(new CategoryViewModel() {Id = 1});
        }

        /// <summary>
        /// 根栏目
        /// </summary>
        /// <returns></returns>
        public ActionResult PartialRoot()
        {
            return View(_categoryManager.Root());
        }

        public ActionResult Summary(string classId)
        {
            var e = _categoryManager.Get(classId);
            return View(new CategoryViewModel(e));
        }
    }
}
